<?PHP
require "../../mainfile.php";
include XOOPS_ROOT_PATH.'/header.php';
if(isset($_GET['ID'])){//echo form to print news story
?>
<HTML>
<HEAD>
<TITLE><?PHP echo strtoupper($xoopsModuleConfig['stationLetters']); ?> News: Print This Article</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="news.css">
<script>
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
</script>
</HEAD>
<body>
<TABLE  WIDTH="502" BORDER="0" CELLSPACING="0" CELLPADDING="1" align="center">
 <tr><td bgcolor="#000000">

<TABLE  WIDTH="500" BORDER="0" CELLSPACING="0" CELLPADDING="5" BGCOLOR="#FFFFFF">
  <TR>

   <TD>          <!--HEADER-->
    <TABLE WIDTH="500" CELLSPACING="0" CELLPADDING="0" BORDER="0" >
     <TR>
	  <TD><SPAN CLASS="text-small"><?PHP echo strtoupper($xoopsModuleConfig['stationLetters']); ?> Local News</SPAN></TD>
	  <TD align="right"><a href="javascript:printWindow()">print this page</a>&nbsp;&nbsp;&nbsp;</TD>
	 </TR>
    </TABLE>

   </TD>
  </TR>

<?PHP
//GET INFO FROM DB
	if($_GET['syndicated'] == 'false' || $_GET['syndicated'] == ""){
			//-------------------------------------------------------------------
			    $result = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("local_news_stories")." WHERE ID = '".$_GET['ID']."'" ) ;
				if ( $result ) {
					$myrow = $xoopsDB->fetchArray($result);
				}
			//-------------------------------------------------------------------
	}else{//get from Syndicated DB
			//-------------------------------------------------------------------
		    $link = mysql_connect($xoopsModuleConfig['syndicationDB_Host'], $xoopsModuleConfig['syndicationDB_User'], $xoopsModuleConfig['syndicationDB_Passaword']) or ($error = mysql_error());
			$Query = "SELECT * FROM CA_SE_News WHERE ID = '".$_GET['ID']."'";
			mysql_select_db($xoopsModuleConfig['syndicationDB']) or ($error = "Could not select database");
			  $result = mysql_query ($Query, $link) or ($error = "Query failed");
	
				if ($result){
					$myrow = mysql_fetch_array($result, MYSQL_ASSOC);
					//$row['headline'];
					}
				mysql_free_result($result);
				mysql_close ($link);

			//-------------------------------------------------------------------
	}
?>


   
   <TR><TD>      
  	<?PHP echo "<h3 style='font-weight:600; padding:0; margin:0; font-size:16px;'>".$myrow['headline']."</h3>
				 <div id='bylinePreview' >".$myrow['byline']."</div>";
				echo" <div id='container'  style='margin-top:10px;margin-bottom:10px;'>".$myrow['dateline']." (".date("Y-m-d").") ". $myrow['tease'];
					if($myrow['body']){
						echo " <div id='bodyHolder' ><br />".trim(html_entity_decode($myrow['body']))."</div>";
					}
				echo"<div id='copy' style='padding-top:5px;' CLASS='article-small' >&copy; Copyright ".date("Y").", ".$myrow['copyright']."</div>
				</div>";
	?>
  

	 </TD></TR> 
	    
</TABLE>
</td></tr></table>	
</body>
</HTML>

<?PHP
}else{//error yo
echo '<h3 style=\'text-align:center;\'>There was an error retrieving the selected news story</h3><P><CENTER><FORM>
<INPUT type="button" value="Close Window" onClick="window.close()"></FORM></CENTER>';}
?>